#!/bin/sh

# Scan for implicit dependencies caused by #include directives

DIR="$1"
shift 1

case "$DIR" in
    "" | ".")
        # current directory
        gcc -MM "$@" | sed -e 's@^\(.*\)\.o:@\1.d \1.o:@'
        ;;
    *)
        gcc -MM "$@" | sed -e "s@^\(.*\)\.o:@$DIR\1.d $DIR\1.o:@"
        ;;
esac
